<template>
	<section style="width:100%">
		<el-tabs v-model="roomDefault" type="card" @tab-click="changeHtml(roomDefault)" style="margin-top: 10px">
			<el-tab-pane label="房间配置" name="first">
				<!--工具条-->
			</el-tab-pane>
			<el-tab-pane label="血池变化" name="blood">
			</el-tab-pane>
		</el-tabs>
		<section v-show="roomDefault == 'first'">
			<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
				<el-form :inline="true">
					<el-form-item label="说明" style="width: 100%;">
						<el-input
								type="textarea"
								:rows="2"
								autosize
								placeholder="请输入内容"
								v-model="textarea"
								style="width: 500px;">
						</el-input>
					</el-form-item>
					<!--<el-form-item label="房间查询选择">-->
						<!--<el-select v-model="roomValue" placeholder="请选择">-->
							<!--<el-option-->
									<!--v-for="item in room"-->
									<!--:key="item.value"-->
									<!--:label="item.label"-->
									<!--:value="item.value">-->
							<!--</el-option>-->
						<!--</el-select>-->
					<!--</el-form-item>-->
					<el-form-item>
						<el-input v-model="roomId" placeholder="房间ID"></el-input>
					</el-form-item>
					<!--<el-form-item label="状态">-->
						<!--<el-select v-model="systemValue" placeholder="请选择">-->
							<!--<el-option-->
									<!--v-for="item in systemState"-->
									<!--:key="item.value"-->
									<!--:label="item.label"-->
									<!--:value="item.value">-->
							<!--</el-option>-->
						<!--</el-select>-->
					<!--</el-form-item>-->
					<!--<el-form-item label="房间当日输赢">-->
						<!--<el-select v-model="bunkoValue" placeholder="请选择">-->
							<!--<el-option-->
									<!--v-for="item in bunko"-->
									<!--:key="item.value"-->
									<!--:label="item.label"-->
									<!--:value="item.value">-->
							<!--</el-option>-->
						<!--</el-select>-->
					<!--</el-form-item>-->
					<el-form-item>
						<el-button type="primary" v-on:click="getRoom(pageSize)">查询</el-button>
					</el-form-item>
					<!--<el-form-item>-->
						<!--<el-button type="primary" >重置</el-button>-->
					<!--</el-form-item>-->
				</el-form>
				<el-form :inline="true">
					<el-form-item label="总输赢">
						<label>{{roomTotal.winlose | division}}</label>
					</el-form-item>
					<el-form-item label="系统当前血池">
						<label>{{roomTotal.value | division}}</label>
					</el-form-item>
					<el-form-item label="当日输赢">
						<label>{{roomTotal.todaywinlose | division}}</label>
					</el-form-item>
					<el-form-item label="当日吐分">
						<label>{{roomTotal.todayout | division}}</label>
					</el-form-item>
					<el-form-item label="当日吃分">
						<label>{{roomTotal.todayeat | division}}</label>
					</el-form-item>
					<el-form-item label="当日吞吐率">
						<label>{{roomTotal.outratio | twoBit}}</label>
					</el-form-item>
					<el-form-item label="暗税总税收">
						<label>{{roomTotal.darktax | division}}</label>
					</el-form-item>
					<el-form-item label="明税总税收">
						<label>{{roomTotal.tax | division}}</label>
					</el-form-item>
					<!--<el-form-item label="当日总点控血池">-->
						<!--<label>{{roomTotal.darktax}}</label>-->
					<!--</el-form-item>-->
				</el-form>
				<el-form :inline="true">
					<!--<el-form-item >-->
						<!--<el-button type="info" @click="editRoomBtn">修改房间配置</el-button>-->
					<!--</el-form-item>-->
					<el-form-item >
						<el-button type="info" @click="addBlood">添加血池控制</el-button>
					</el-form-item>
					<el-form-item >
						<el-button type="info" @click="bloodControl">血池控制记录</el-button>
					</el-form-item>
					<!--<el-form-item >-->
						<!--<el-button type="info" @click="history">历史吞吐率</el-button>-->
					<!--</el-form-item>-->
					<el-form-item>
						<el-button type="info" @click="bloodSwitch">血池变化</el-button>
					</el-form-item>
				</el-form>
			</el-col>
			<!--列表-->
			<el-table :data="roomList" highlight-current-row v-loading="listLoading" style="width: 100%;" :default-sort = "{prop: 'id'}">
				<!--<el-table-column type="selection" width="55">-->
				<!--</el-table-column>-->
				<el-table-column prop="id" label="房间ID" width="100" sortable>
				</el-table-column>
				<el-table-column prop="title" label="房间名称" width="200">
				</el-table-column>
				<el-table-column prop="winlose" label="总输赢" width="150" sortable>
					<template slot-scope="scope">
						<span>{{scope.row.winlose | division}}</span>
					</template>
				</el-table-column>
				<el-table-column prop="todaywinlose" label="当日输赢" width="150">
					<template slot-scope="scope">
						<span>{{scope.row.todaywinlose | division}}</span>
					</template>
				</el-table-column>
				<!--<el-table-column prop="name" label="点控血池" width="100">-->
				<!--</el-table-column>-->
				<!--<el-table-column prop="name" label="当日点控血池" width="150">-->
				<!--</el-table-column>-->
				<el-table-column prop="balaceline" label="血池平衡值" width="120">
					<template slot-scope="scope">
						<span>{{scope.row.balaceline | division}}</span>
					</template>
				</el-table-column>
				<el-table-column prop="value" label="当前血池" width="150">
					<template slot-scope="scope">
						<span>{{scope.row.value | division}}</span>
					</template>
				</el-table-column>
				<el-table-column prop="stateTxt" label="状态" width="120">
				</el-table-column>
				<el-table-column prop="outratio" label="吐分率" width="80">
					<template slot-scope="scope">
						<span>{{scope.row.outratio | twoBit}}</span>
					</template>
				</el-table-column>
				<el-table-column prop="darktax" label="暗税总税收" width="150">
					<template slot-scope="scope">
						<span>{{scope.row.darktax | division}}</span>
					</template>
				</el-table-column>
				<el-table-column prop="todaydarktax" label="当日暗税收" min-width="150">
					<template slot-scope="scope">
						<span>{{scope.row.todaydarktax | division}}</span>
					</template>
				</el-table-column>
				<el-table-column prop="tax" label="明税总税收" width="150">
					<template slot-scope="scope">
						<span>{{scope.row.tax | division}}</span>
					</template>
				</el-table-column>
				<el-table-column prop="todaytax" label="当日明税收" min-width="150">
					<template slot-scope="scope">
						<span>{{scope.row.todaytax | division}}</span>
					</template>
				</el-table-column>
			</el-table>

			<!--工具条-->
			<el-col :span="24" class="toolbar">
				<el-pagination layout="sizes, total, prev, pager, next" :page-sizes="[15, 30, 50]" @current-change="handleCurrentChange" @size-change="handleSizeChange"  :page-size="pageSize" :total="total" style="float:right;">
				</el-pagination>
			</el-col>

			<!--<el-dialog title="修改房间配置" v-model="editRoomVisible" :close-on-click-modal="false">-->
				<!--<el-form :model="editRoom" label-width="120px" :rules="editRoomRules" ref="editRoom">-->
					<!--<el-form-item label="房间名称" prop="name">-->
						<!--<el-select v-model="roomNameValue" placeholder="请选择">-->
							<!--<el-option-->
									<!--v-for="item in roomName"-->
									<!--:key="item.value"-->
									<!--:label="item.label"-->
									<!--:value="item.value">-->
							<!--</el-option>-->
						<!--</el-select>-->
					<!--</el-form-item>-->
					<!--<el-form-item label="当前血池平衡值">-->
						<!--<el-input v-model="filters.name" placeholder="当前血池平衡值" disabled></el-input>-->
					<!--</el-form-item>-->
					<!--<el-form-item label="修改血池平衡值">-->
						<!--<el-input v-model="filters.name" placeholder="修改血池平衡值"></el-input>-->
					<!--</el-form-item>-->
				<!--</el-form>-->
				<!--<div slot="footer" class="dialog-footer">-->
					<!--<el-button @click.native="editRoomVisible = false">取消</el-button>-->
					<!--<el-button type="primary" @click.native="editSubmit" :loading="editLoading">提交</el-button>-->
				<!--</div>-->
			<!--</el-dialog>-->
			<el-dialog title="添加血池控制" v-model="governVisible" :close-on-click-modal="false">
				<el-form :model="govern" label-width="100px" :rules="governRules" ref="govern">
					<el-form-item label="房间信息" prop="governValue">
						<el-select v-model="govern.gameId" placeholder="请选择">
							<el-option
									v-for="item in roomName"
									:key="item.id"
									:label="item.id + item.title"
									:value="item.id">
							</el-option>
						</el-select>
					</el-form-item>
					<!--<el-form-item label="房间名称">-->
						<!--<el-date-picker-->
								<!--v-model="value1"-->
								<!--type="datetime"-->
								<!--placeholder="选择日期时间"-->
								<!--value-format="yyyy-MM-dd HH:mm:ss">-->
						<!--</el-date-picker>-->
					<!--</el-form-item>-->
					<el-form-item label="血池目标值">
						<el-input-number v-model="govern.number"></el-input-number>
					</el-form-item>
				</el-form>
				<div slot="footer" class="dialog-footer">
					<el-button @click.native="governVisible = false">取消</el-button>
					<el-button type="primary" @click.native="governSubmit(govern)" :loading="editLoading">提交</el-button>
				</div>
			</el-dialog>
			<el-dialog title="血池控制列表" v-model="controlVisible" :close-on-click-modal="false">
				<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
					<el-form :inline="true" :model="controlObj">
						<el-form-item label="房间信息">
							<el-select v-model="controlObj.controlValue" placeholder="请选择">
								<el-option
										v-for="item in roomName"
										:key="item.id"
										:label="item.id + item.title"
										:value="item.id">
								</el-option>
							</el-select>
						</el-form-item>
						<el-form-item >
							<el-input v-model="controlObj.operatorid" placeholder="操作人账号"></el-input>
						</el-form-item>
						<el-form-item label="血池总收益" style="width:40%">
							<label>{{bloodProfit | division}}</label>
						</el-form-item>
						<el-form-item label="开始时间">
							<el-date-picker
									v-model="controlObj.logatstart"
									type="datetime"
									value-format="yyyy-MM-dd HH:mm:ss"
									placeholder="选择日期">
							</el-date-picker>
						</el-form-item>
						<el-form-item label="结束时间">
							<el-date-picker
									v-model="controlObj.logatend"
									type="datetime"
									value-format="yyyy-MM-dd HH:mm:ss"
									placeholder="选择日期">
							</el-date-picker>
						</el-form-item>
						<el-form-item>
							<el-button type="primary" v-on:click="getControl">查询</el-button>
						</el-form-item>
					</el-form>
				</el-col>
				<el-table :data="controlList" highlight-current-row v-loading="controlLoading"  style="width: 100%;">
					<el-table-column prop="gameId" label="游戏房间ID" width="110">
					</el-table-column>
					<el-table-column prop="gameTitle" label="房间名称" width="200">
					</el-table-column>
					<el-table-column prop="time" label="执行时间" width="200">
					</el-table-column>
					<el-table-column prop="value" label="控制分数" width="200">
						<template slot-scope="scope">
							<span>{{scope.row.value | division}}</span>
						</template>
					</el-table-column>
					<el-table-column prop="operatorId" label="操作人" min-width="100">
					</el-table-column>
					<!--<el-table-column label="操作" min-width="150">-->
						<!--<template scope="scope">-->
							<!--<el-button size="small" @click="handleDel(scope.$index, scope.row)">暂停</el-button>-->
							<!--<el-button type="danger" size="small" @click="handleDel(scope.$index, scope.row)">取消</el-button>-->
						<!--</template>-->
					<!--</el-table-column>-->
				</el-table>
			</el-dialog>
			<!--<el-dialog title="历史吞吐率" v-model="historyVisible" :close-on-click-modal="false">-->
				<!--<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">-->
					<!--<el-form :inline="true" :model="filters">-->
						<!--<el-form-item label="房间查询选择">-->
							<!--<el-select v-model="roomValue" placeholder="请选择">-->
								<!--<el-option-->
										<!--v-for="item in room"-->
										<!--:key="item.value"-->
										<!--:label="item.label"-->
										<!--:value="item.value">-->
								<!--</el-option>-->
							<!--</el-select>-->
						<!--</el-form-item>-->
						<!--<el-form-item style="width:50%">-->
							<!--<el-input v-model="filters.name" placeholder="房间信息"></el-input>-->
						<!--</el-form-item>-->
						<!--<el-form-item label="开始时间">-->
							<!--<el-date-picker-->
									<!--v-model="value1"-->
									<!--type="datetime"-->
									<!--value-format="yyyy-MM-dd HH:mm:ss"-->
									<!--placeholder="选择日期">-->
							<!--</el-date-picker>-->
						<!--</el-form-item>-->
						<!--<el-form-item label="结束时间">-->
							<!--<el-date-picker-->
									<!--v-model="value1"-->
									<!--type="datetime"-->
									<!--value-format="yyyy-MM-dd HH:mm:ss"-->
									<!--placeholder="选择日期">-->
							<!--</el-date-picker>-->
						<!--</el-form-item>-->
						<!--<el-form-item>-->
							<!--<el-button type="primary" v-on:click="getRoom">查询</el-button>-->
						<!--</el-form-item>-->
						<!--<el-form-item label="总输赢" style="padding-left: 30px">-->
							<!--<span>1213212</span>-->
						<!--</el-form-item>-->
					<!--</el-form>-->
				<!--</el-col>-->
				<!--<el-table :data="users" highlight-current-row v-loading="listLoading"  style="width: 100%;">-->
					<!--<el-table-column prop="name" label="时间" width="150">-->
					<!--</el-table-column>-->
					<!--<el-table-column prop="name" label="游戏房间ID" width="110">-->
					<!--</el-table-column>-->
					<!--<el-table-column prop="name" label="房间名称" width="100">-->
					<!--</el-table-column>-->
					<!--<el-table-column prop="name" label="当日输赢" width="200">-->
					<!--</el-table-column>-->
					<!--<el-table-column prop="name" label="当日吐分" width="150">-->
					<!--</el-table-column>-->
					<!--<el-table-column prop="name" label="当日吃分" width="100">-->
					<!--</el-table-column>-->
					<!--<el-table-column prop="name" label="吞吐率" width="100">-->
					<!--</el-table-column>-->
				<!--</el-table>-->
			<!--</el-dialog>-->
		</section>
		<section v-show="roomDefault == 'blood'" style="width:100%;margin-top:15px">
			<el-form :inline="true" :model="filters">
				<el-form-item label="房间信息">
					<el-select v-model="roomValue" placeholder="请选择">
						<el-option
								v-for="item in room"
								:key="item.id"
								:label="item.id + item.title"
								:value="item.id">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="开始时间">
					<el-date-picker
							v-model="startDate"
							type="datetime"
							value-format="yyyy-MM-dd HH:mm:ss"
							placeholder="选择日期">
					</el-date-picker>
				</el-form-item>
				<el-form-item label="结束时间">
					<el-date-picker
							v-model="endDate"
							type="datetime"
							value-format="yyyy-MM-dd HH:mm:ss"
							placeholder="选择日期">
					</el-date-picker>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" v-on:click="getBlood">查询</el-button>
				</el-form-item>
			</el-form>
			<div id="chartLine" style="width:100%; height:400px;"></div>
			<el-table :data="bloodTable" highlight-current-row v-loading="listLoading"  style="width: 100%">
				<el-table-column prop="time" label="时间">
				</el-table-column>
				<el-table-column prop="value" label="剩余血池">
				</el-table-column>
				<el-table-column prop="balanceLine" label="血池平衡">
				</el-table-column>
				<el-table-column prop="bottomLine" label="血池触底">
				</el-table-column>
			</el-table>
			<el-col :span="24" class="toolbar">
				<el-pagination layout="total, prev, pager, next" @current-change="bloodChange" :page-size="10"  :total="bloodTotal" style="float:right;">
				</el-pagination>
			</el-col>
		</section>
	</section>
</template>

<script>
    import echarts from 'echarts'

	export default {
		data() {
			return {
			    roomTotal:{
                    darktax:'',
                    outratio:'',
                    todayeat:'',
                    todayout:'',
                    todaywinlose:'',
                    value:'',
                    winlose:''
				},
                bloodProfit:'',
                roomId:'',
                value1:'',
                bloodTable:[],
                startDate:'',
				endDate:'',
                textarea:'1.输赢值正数为系统赢，负数为系统赢\n2.点控血池正数为系统赢，负数为系统输\n3.点控无法在百人场生效，只能通过血池控制房间',
                editRoomVisible:false,
                roomNameValue:'',
                editRoom:[],
                roomName:[],
                governVisible:false,
                govern:{
                    gameId:'',
					number:''
				},
                controlVisible:false,
                controlValue:'',
                controlObj:{
                    controlValue:'',
                    operatorid:'',
                    logatstart:'',
                    logatend:''
				},
				searchBtn:true,
                controlList:[],
                controlLoading:false,
                historyVisible:false,
				filters: {
					name: ''
				},
                roomList: [],
                users:[],
				roomDefault: 'first',
                chartLine: null,
				total:0,
				bloodTotal: 0,
				page:1,
				pageSize:15,
				bloodpage: 1,
				listLoading: false,
				sels: [],//列表选中列
                editableTabs: [
                    {
                    title: 'Tab 1',
                    name: '1',
                    content: 'Tab 1 content'
                }
                ],
				editFormVisible: false,//编辑界面是否显示
				editLoading: false,
                editRoomRules: {
					name: [
						{ required: true, message: '请输入姓名', trigger: 'blur' }
					]
				},
				//编辑界面数据
				editForm: {
					id: 0,
					name: '',
					sex: -1,
					age: 0,
					birth: '',
					addr: ''
				},

				addFormVisible: false,//新增界面是否显示
				addLoading: false,
                governRules: {
                    governValue: [
						{ required: true, message: '请选择房间信息', trigger: 'blur' }
					]
				},
				//新增界面数据
				addForm: {
					name: '',
					sex: -1,
					age: 0,
					birth: '',
					addr: ''
				},
                room: [],
                roomValue: '',
                systemState: [
                    {
                        value: '1',
                        label: '系统吃分'
                    }, {
                        value: '2',
                        label: '系统吐分'
                    }
                ],
                systemValue: '1',
                bunko: [
                    {
                        value: 0,
                        label: '全部'
                    },
                    {
                        value: 1,
                        label: '输'
                    }, {
                        value: 2,
                        label: '赢'
                    }
                ],
                bunkoValue: '0',
                //图表数据
                downDate:[],
                bloodBalance:[],
                bloodPool:[],
                bloodDown:[]
			}
		},
        created(){
            this.startDate =  this.Todate1(new Date(),'yyyy-MM-dd HH:mm:ss')
            this.endDate =  this.Todate(new Date(),'yyyy-MM-dd HH:mm:ss')
            this.controlObj.logatstart =  this.Todate1(new Date(),'yyyy-MM-dd HH:mm:ss')
            this.controlObj.logatend =  this.Todate(new Date(),'yyyy-MM-dd HH:mm:ss')
			this.getGameList()
			this.getRoom(this.pageSize)
        },
		methods: {

		    getGameList(){
		        this.$axios.get('/games',{},this.global().token).then((res)=>{
		            if (res.status == 200){
		                this.room = res.data
                        this.roomName = res.data
					}
				})
			},
            drawLineChart() {
                // var myChart=document.getElementById('chartLine');
                // myChart.style.width=window.innerWidth+'px';
                // this.chartLine = echarts.init(document.getElementById('chartLine'));
                this.chartLine.setOption({
                    title: {
                        text: '血池变化'
                    },
                    tooltip: {
                        trigger: 'axis'
                    },
                    legend: {
                        data: ['血池平衡', '血池', '血池触底']
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        bottom: '3%',
                        containLabel: true
                    },
                    xAxis: {
                        type: 'category',
                        boundaryGap: false,
                        data: this.downDate
                    },
                    yAxis: {
                        type: 'value'
                    },
                    series: [
                        {
                            name: '血池平衡',
                            type: 'line',
                            data: this.bloodBalance
                        },
                        {
                            name: '血池',
                            type: 'line',
                            data:  this.bloodPool
                        },
                        {
                            name: '血池触底',
                            type: 'line',
                            data: this.bloodDown
                        }
                    ]
                });
                this.chartLine.resize();
            },
            editRoomBtn(){
                this.editRoomVisible = true;
			},
            addBlood(){
                this.governVisible = true;
            },
            bloodControl(){
                this.controlVisible = true;
            },
            history(){
                this.historyVisible = true;
            },
            bloodSwitch(){
                this.roomDefault = 'blood';
            },
            changeHtml(value){
                if (value == 'first'){
                    this.getRoom(this.pageSize);
				}
			},
            handleSizeChange(val) {
                this.pageSize = val
                this.getRoom(this.pageSize);
            },
			handleCurrentChange(val) {
				this.page = val;
				this.getRoom(this.pageSize);
			},
            bloodChange(val) {
                this.bloodpage = val;
                this.getBloodTable();
            },
			//获取房间列表
			getRoom(page) {
				this.listLoading = true;
				this.$axios.get('/game-blood-slots?gameid='+this.roomId+'&index='+this.page+'&size='+page,{},this.global().token).then((res)=>{
                    this.listLoading = false;
					if(res.status == 200){
					    this.total = res.data.count
					    this.roomTotal = res.data.statistics
						let room = res.data.data
						room.forEach((val)=>{
						    val.stateTxt = val.status.toString().replace('0','系统吃分').replace('1','系统吐分')
						})
						this.roomList = room
					}else{
                        this.$message({message: res.data, type: 'error'});
					}
				})
			},
            //添加血池控制
            governSubmit(govern){
		        let governNum = govern.number * 1000
				this.$axios.patch('/blood-slot-control/'+govern.gameId,{value:governNum},this.global().token).then((res)=>{
				    if (res.status == 200){
                        this.$message({message: '添加成功', type: 'success'});
                        this.governVisible = false
					}else{
                        this.$message({message: res.data, type: 'error'});
					}
				})
			},
            //血池控制列表
            getControl(){
                let startDate,endDate
                if (this.controlObj.logatstart || this.controlObj.logatend){
                    startDate = Date.parse(new Date(this.controlObj.logatstart))
                    endDate = Date.parse(new Date(this.controlObj.logatend))
                }else{
                    startDate = ''
                    endDate =''
                }
                console.log(startDate)
		        this.$axios.get('/blood-slot-controls?gameid='+this.controlObj.controlValue+'&operatorid='+this.controlObj.operatorid+'&logatstart='+startDate+'&logatend='+endDate,{},this.global().token).then((res)=>{
                    if (res.status == 200){
                        let controlTable = res.data.data
                        controlTable.forEach((val)=>{
                            val.time = this.changeDate(val.logAt)
                        })
                        this.controlList = controlTable
						this.bloodProfit = res.data.amount
                    }else{
                        this.$message({message: res.data, type: 'error'});
                    }
				})
			},
            getBlood(){
                if (this.roomValue == ''){
                    this.$message({message: '请选择房间信息', type: 'error'});
                    return
				}
                if (this.startDate == '' || !this.startDate){
                    this.$message({message: '请选择开始时间', type: 'error'});
                    return
                }
                if (this.endDate == '' || !this.endDate){
                    this.$message({message: '请选择结束时间', type: 'error'});
                    return
                }
				if (this.searchBtn){
                    this.searchBtn = false
                    this.getBloodTable()
                    this.getBloodLine()
				}
			},
			getBloodTable(){
                let startDate,endDate
                if (this.startDate || this.endDate){
                    startDate = Date.parse(new Date(this.startDate))
                    endDate = Date.parse(new Date(this.endDate))
                }else{
                    startDate = ''
                    endDate =''
                }
                this.$axios.get('/blood-slot-changes?gameid='+this.roomValue+'&index='+this.bloodpage+'&size=10&logatstart='+startDate+'&logatend='+endDate,{},this.global().token).then((res)=>{
                    if (res.status == 200){
                        this.bloodTotal = res.data.count
                        let bloodTable = res.data.data
                        bloodTable.forEach((val)=>{
                            val.time = this.changeDate(val.logAt)
                            val.balanceLine = parseFloat(val.balanceLine)/1000
                            val.value = parseFloat(val.value)/1000
                            val.bottomLine = parseFloat(val.bottomLine)/1000
                        })
                        this.bloodTable = bloodTable
                        this.listLoading = false
                    }
                })
			},
			getBloodLine(){
                let startDate,endDate
                if (this.startDate || this.endDate){
                    startDate = Date.parse(new Date(this.startDate))
                    endDate = Date.parse(new Date(this.endDate))
                }else{
                    startDate = ''
                    endDate =''
                }
                this.downDate=[]
                this.bloodBalance=[]
                this.bloodPool=[]
                this.bloodDown=[]
                this.$axios.get('/blood-slot-changes-chart?gameid='+this.roomValue+'&logatstart='+startDate+'&logatend='+endDate,{},this.global().token).then((res)=>{
                    if (res.status == 200){
                        this.searchBtn = true
                        let blood = res.data
                        blood.forEach((val)=>{
                            this.downDate.push(this.changeDate(val.logAt))
                            this.bloodBalance.push(parseFloat(val.balanceLine)/1000)
                            this.bloodPool.push(parseFloat(val.value)/1000)
                            this.bloodDown.push(parseFloat(val.bottomLine)/1000)
                        })
                        this.drawLineChart()
                    }
                })
			},
			//显示编辑界面
			handleEdit: function (index, row) {
				this.editFormVisible = true;
				this.editForm = Object.assign({}, row);
			},
			//显示新增界面
			handleAdd: function () {
				this.addFormVisible = true;
				this.addForm = {
					name: '',
					sex: -1,
					age: 0,
					birth: '',
					addr: ''
				};
			},
		},
		mounted() {
			this.getRoom(this.pageSize);
            let myChart = document.getElementById(('chartLine'));
            myChart.style.width = window.innerWidth - 230 + 'px';
            this.chartLine = echarts.init(myChart);
            let _this = this;
            window.addEventListener("resize", function () {
                let myChart = document.getElementById(('chartLine'));
                myChart.style.width = window.innerWidth - 230 + 'px';
                _this.chartLine.resize();
            });
            this.drawLineChart()
		}
	}

</script>

<style scoped lang="stylus">
</style>